/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.yihu.wlyy.entity.doctor.DoctorStatisticsConsult;

public interface DoctorStatisticsConsultDao extends PagingAndSortingRepository<DoctorStatisticsConsult, Long>, JpaSpecificationExecutor<DoctorStatisticsConsult> {
	
	@Query("select a from DoctorStatisticsConsult a where a.doctor = ?1 and a.date = ?2")
	DoctorStatisticsConsult findByDoctorDate(String doctor, int date);

	@Modifying
	@Query("update DoctorStatisticsConsult a set a.typeTeam = a.typeTeam + 1, a.usersTema = a.usersTema + 1 where a.doctor = ?1 and a.date = ?2")
	int increaseTeam(String doctor, int date);
	
	@Modifying
	@Query("update DoctorStatisticsConsult a set a.typeMovi = a.typeMovi + 1, a.usersMovi = a.usersMovi + 1 where a.doctor = ?1 and a.date = ?2")
	int increaseMovi(String doctor, int date);
}
